<template>
    <div style="width: 400px;margin:auto">
        <el-form :model="form" label-width="120px">
            <el-form-item label="用户名">
                <el-input v-model="formModel.username" disabled />
            </el-form-item>
            <el-form-item label="学号">
                <el-input v-model="formModel.no" disabled />
            </el-form-item>
            <el-form-item label="专业">
                <el-input v-model="formModel.majorName" disabled />
            </el-form-item>
            <el-form-item label="院系">
                <el-input v-model="formModel.collegeName" disabled />
            </el-form-item>
            <el-form-item label="姓名">
                <el-input v-model="formModel.trueName" />
            </el-form-item>
            <el-form-item label="性别">
                <el-radio-group v-model="formModel.gender">
                    <el-radio label="男">男</el-radio>
                    <el-radio label="女">女</el-radio>
                </el-radio-group>
            </el-form-item>
            <el-form-item label="密码">
                <el-input v-model="formModel.password" />
            </el-form-item>
            <el-form-item>
                <el-button type="primary" @click="onSubmit">提交</el-button>
            </el-form-item>
        </el-form>
    </div>
</template>

<script>
import request from '@/utils/http';
import { ElMessage } from 'element-plus'
export default {
    data() {
        return {
            formModel: {}
        }
    },
    methods: {
        onSubmit() {
            request.post('/student/owner', this.formModel)
                .then(response => {
                    if (response.code === 200) {
                        ElMessage({
                            message: '操作成功',
                            grouping: true,
                            type: 'success',
                        })
                    } else {
                        ElMessage({
                            message: response.msg,
                            grouping: true,
                            type: 'error',
                        })
                    }
                })
        }
    },
    created() {
        request.get('/student/info')
            .then(response => {
                this.formModel = response.data
            })
    }
}
</script>

<style></style>